package com.erbao.thread.juc;

import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.Vector;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * @author CaoBaoYin
 * @since 2022/3/4 20:51
 */
public class TicketList {

    static List<String> list = new Vector<>();
    // static List<String> list = new ArrayList<>();
    static Queue<String> queue = new ConcurrentLinkedQueue<>();

    static {
        for (int i = 0; i < 1000; i++) {
            // list.add("票号："+i);
            queue.add("票号："+i);
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                /*while (list.size() > 0) {
                    list.remove(0);
                }*/
                while (true) {
                    String s = queue.poll();
                    if (s == null) break;
                    System.out.println("售出"+s);
                }
            }).start();
        }
    }

}
